# Left 	   = 0x31
# Straight = 0x32
# Right    = 0x33
# Stop     = 0x34
# RotLef   = 0x35
# Exit4restart = 0x40
import serial
import time
import msvcrt

Strgt 	= chr(0x32)
Left 	= chr(0x31)
Right	= chr(0x33)
Stop	= chr(0x34)
RotL 	= chr(0x35)

ser = serial.Serial('COM4', 38400, timeout= 0.1)
keyboardval = 's'
ticks       = 0
MaxTicks    = 50

while ticks < MaxTicks :
	ticks = ticks + 1
	if ticks <= 40:
		ser.write(Strgt)
		print Strgt
		print "straight", ticks
	if (ticks >40) & (ticks <= 45):
		ser.write(Left)
		print "left" , ticks
	if (ticks >45) & (ticks <= 50):
		ser.write(Right)
		print "right", ticks
	if (ticks >50) & (ticks <= 80):
		ser.write(RotL)
		print "rotate", ticks
	time.sleep(0.25)
	ser.write(Stop)
ser.write(Stop)
ser.close()			
print "End of program"